package com.telsoft.hms.util;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

public class StringUtil {
	public static String getPoolName(String key) {
		return "";
	}

	public static String getNameSchema(String key) {
		return "";
	}

	public static String getPropValues(String propFileName) throws IOException {
		Properties pro = new Properties();
		String strNameDBPool;
		try {
			pro.load(new FileInputStream(propFileName));
			strNameDBPool = pro.getProperty("name");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			throw e;
		}
		return strNameDBPool;
	}

	public static String getHospitalKey(String userName) {
		if (!isNullOrEmpty(userName)) {
			String regex = "^[^@]+[@]{1}[^@]+$";
			boolean result = userName.matches(regex);
			String[] strSplit = userName.split("@");
			if (strSplit.length == 2 && result) {
				return strSplit[1];
			}
		}
		return "";
	}

	public static boolean isNullOrEmpty(String input) {
		return (input == null || input.trim().length() == 0);
	}
}
